ShortcutKey2URL: SS
hr.icon
code: script.js
function easyDiary(body_lines) {
const date = new Date();
const toMmOrDd = num => num.toString().padStart(2, '0');
const todays = [
date.getFullYear().toString(),
toMmOrDd(date.getMonth() + 1),
toMmOrDd(date.getDate()),
];
const title = todays.join("%2F");
const timestamp = date.toLocaleString();
const body =
timestamp + " " + "#yyyy/mm/dd" +
"\n" +
(Array.isArray(body_lines) ? body_lines.join("\n") : body_lines) +
"\n";
/* Chromeのポップアップブロックを防ぐ。どうしてそうなるのかは未解明。 */
window.open(
);
}
function quickQuotes() {
var title = document.title;
var replacedStrings = {
":": ":",
"\\[": "[",
"\\]": "]",
"\\|": "|",
};
for (var key in replacedStrings) {
title = title.replace(new RegExp(key, "g"), replacedStringskey); }
var lines = ["+ title + " " + window.location.href + ""];
var quote = window.getSelection().toString();
if (quote.trim())
lines = lines.concat(
quote
.replace(/^\n/g, "")
.split(/\n/g)
.map(function (line) {
return " > " + line;
})
);
return lines;
}
function quickQuotesAtScrapbox() {
var project_title = "[/" + scrapbox.Project.name + "/" + scrapbox.Page.title;
if (document.getElementsByClassName("cursor-line")0) { var quote = window.getSelection().toString();
if (window.getSelection().toString() == "") {
var url =
project_title +
"#" +
document.getElementsByClassName("cursor-line")0.id.slice(1) + "]";
} else {
var lines = quote.split(/\n/g).map(function (line) {
return " > " + line;
});
var url =
project_title +
"#" +
document.getElementsByClassName("cursor-line")0.id.slice(1) + "]" +
"\r" +
lines.join("\n");
}
} else {
var url = project_title + "]";
}
return url;
}
if (document.location.href.match(/scrapbox.io/)) {
var body = quickQuotesAtScrapbox();
} else {
var body = quickQuotes();
}
easyDiary(body);